package com.piece.file.preview;

import com.piece.core.framework.util.file.FileUtil;
import com.piece.file.support.FileAttribute;
import org.springframework.stereotype.Service;
import org.springframework.ui.Model;
import javax.servlet.http.HttpServletRequest;

/**
 * 处理无法识别文件
 */
@Service
public class OtherFilePreview implements FilePreviewHandle {

    @Override
    public String handle(FileAttribute fileAttribute, HttpServletRequest request, Model model, boolean edit) {
        String fileName = fileAttribute.getName();
        String suffix = FileUtil.getFileSuffix(fileName);
        model.addAttribute("fileType", suffix);
        model.addAttribute("msg", "系统还不支持该格式文件的在线预览");
        return "/file/fileNotSupported";
    }
}
